MODULE module_namelist_var 
  INTEGER,PARAMETER ::  level_max=50 ! the max number of vertical layers    
  INTEGER,PARAMETER ::  files_max=80 ! the max number of input files

  TYPE Tvarinfo
    CHARACTER(LEN=20)                :: name       ! variable name 
    CHARACTER(LEN=40)                :: chsname    ! variable chinese name 
    INTEGER                          :: nlevel, &  ! total number of levels 
                                        ndim       ! total number of dimensions
    INTEGER,DIMENSION(level_max)     :: dims       ! dimension size
    
    REAL,DIMENSION(level_max)        :: levels, &  ! level value 
                                        bolds, &   ! bold value for micaps 
                                                   ! variables
                                        intervals  ! interval value between 
                                                   ! two isolines 
  END TYPE 

  TYPE(Tvarinfo),allocatable,dimension(:) :: & 
                var_2d, &       ! variable info of 2D 
                var_3d, &       ! variable info of 3D
                var_own2d, &    ! variable info of 2D post-processed 
                var_own3d, &    ! variable info of 3D post_processed 
                var_soil        ! variable info of soil 

  INTEGER    :: isoil, &        ! total number of soil layers
                ivarsoil, &     ! total number of soil variables
                ivar3d, &       ! total number of 3D variables
                ivar2d, &       ! total number of 2D variables
                ivarown3d, &    ! total number of 3D post-processed variables
                ivarown2d       ! total number of 2D post-processed variables

  CHARACTER*200  :: in_files(files_max)    ! input files in NetCDF format
  CHARACTER*200  :: data_root   ! directory of output files
  INTEGER        :: nfiles      ! the total number of input files
  INTEGER        :: grid_x, &
                    grid_y      ! total number in x and y direction
  CHARACTER*200  :: times_str   ! output time index 
  INTEGER        :: interp_h, & ! 
                    interp_v, & !interp is the type of interpolating
                    nlevel      ! total layers in z direction
  REAL,allocatable::surf_values(:)! values of each layer in string form
  INTEGER,allocatable::times_idx(:)! output time index 
  INTEGER        :: lonlat_user   ! index of using user defined lon/lat info 
  REAL           ::min_lat_user,& ! user defined minimal latitude for output 
                   max_lat_user,& ! user defined maximal latitude for output 
                   min_lon_user,& ! user defined minimal latitude for output 
                   max_lon_user  ! user defined maximal latitude for output 

  LOGICAL        :: overwrite    ! overwrite the output file or not
  
  CONTAINS 
  SUBROUTINE nullify_module_namelist_var
    if (allocated(var_2d)) deallocate(var_2d)
    if (allocated(var_own2d)) deallocate(var_own2d)
    if (allocated(var_3d)) deallocate(var_3d)
    if (allocated(var_own3d)) deallocate(var_own3d)
    if (allocated(var_soil)) deallocate(var_soil)
    if (allocated(surf_values)) deallocate(surf_values)
    if (allocated(times_idx)) deallocate(times_idx)
  END SUBROUTINE 

END MODULE module_namelist_var 
